window.onload = function() {
	dragdrop('teste1', 'teste1');
	dragdrop('teste2', 'teste2');
	dragdrop('dashBoard', 'dashBoard');
	
};

function addTextAreaIE() {
	vCont = vCont + 1;//count

	var inpt = document.getElementById('a').value = vCont;
	var div = document
	.createElement('<div style="position: absolute; width: 150px; height: 150px; border: 0px solid black; left: 250px; top: 250px;">');
	var but = document.createElement('<textarea style="width: 150px; height: 150px; overflow:hidden; background-color:#FFFF99; border: 0px;">');
	div.setAttribute("id", "a_" + vCont);
	div.appendChild(but);
	document.body.appendChild(div);
	dragdrop('a_' + vCont, 'a_' + vCont);
}

function removeElement(divNum) {
	var d = document.getElementById('myDiv');
	var olddiv = document.getElementById(divNum);
	d.removeChild(olddiv);
}

vCont = 0;
function addLabel() {
	vCont = vCont + 1;//count

	var inpt = document.getElementById('a').value = vCont;
	var div = document.createElement("div");
	div.setAttribute("style", "position: absolute; width: 150px; height: 150px; border: 0px solid black; left: 250px; top: 250px;");
	var but = document.createElement("input");
	but.setAttribute("type", "text");
	but.setAttribute("size", "30");
	but.setAttribute("class", "transparent");
	but.setAttribute("style", "font-weight: bold; border:0px; text-align: center");
	div.setAttribute("id", "b_" + vCont);
	but.setAttribute("value", "<TAG>");
	div.appendChild(but);
	document.body.appendChild(div);
	dragdrop('b_' + vCont, 'b_' + vCont);
}
function addLabelIE() {
	vCont = vCont + 1;//count

	var inpt = document.getElementById('a').value = vCont;
	var div = document.createElement('<div style="position: absolute; width: 150px; height: 150px; border: 0px solid black; left: 250px; top: 250px;">');
	var but = document.createElement('<input type="text" size="30" class="transparent" style="font-weight: bold; border:0px; text-align: center">');
	div.setAttribute("id", "b_" + vCont);
	but.setAttribute("value", "<TAG>");
	div.appendChild(but);
	document.body.appendChild(div);
	dragdrop('b_' + vCont, 'b_' + vCont);
}

function Iniciar() {

	editor.document.designMode = 'On';

}

function italico() {

	editor.document.execCommand('italic', false, null);

}

function contaCheckbox(selecionados){
	var inputs, x, selecionados=0;
	inputs = document.getElementsByTagName('input');
	for(x=0;x<inputs.length;x++){
		if(inputs[x].type=='checkbox'){
			if(inputs[x].checked==true && inputs[x].id == 'check'){
				selecionados++;
			}
		}
	}
	return selecionados;
}

function pegaQuantidade(){
	var total; 
	total = contaCheckbox();
	if (total > 0){
		alert("Quantidade retornada: " + total);		
	}else{
		alert("Selecione pelo menos um checkbox");
	} 
}

function textarea_selecionado(textarea) {
	var selecionado = "";
	if(document.selection){
		selecionado = document.selection.createRange().text;
	}
	else if(typeof(textarea.selectionStart) != "undefined") {
		selecionado = textarea.value.substring(textarea.selectionStart, textarea.selectionEnd);
	}

	document.write(selecionado);
}
